package cj.web.marriage.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.marriage.domain.MarriageInfor;

/**
 * 
 * @author 
 *
 */
@DAO
public interface MarriageInforDAO{
	
	@SQL("SELECT * FROM MarriageInfor WHERE title like '%##(:t.title)%' or man like '%##(:t.man)%' or manCard like '%##(:t.manCard)%' or woman like '%##(:t.woman)%' or womanCard like '%##(:t.womanCard)%' ) ORDER BY orderAt DESC LIMIT :t.start,:t.length ")
    List<MarriageInfor> query(@SQLParam("t") MarriageInfor marriageInfor);
    
    @SQL("select * from MarriageInfor where id=:1")
    MarriageInfor queryById(String id);
    
    @SQL("INSERT INTO MarriageInfor (code,title,man,manCard,woman,womanCard,photo,createAt) VALUES (:t.code,:t.title,:t.man,:t.manCard,:t.woman,:t.womanCard,:t.photo,now())")
    void create(@SQLParam("t") MarriageInfor marriageInfor);
	
	@SQL("UPDATE MarriageInfor SET code=:t.code,title=:t.title,man=:t.man,manCard=:t.manCard,woman=:t.woman,womanCard=:t.womanCard,photo=:t.photo WHERE id=:t.id")
    void update(@SQLParam("t") MarriageInfor marriageInfor);
    
    @SQL("SELECT id,title,man,manCard,woman,womanCard,orderAt FROM	MarriageInfor WHERE 1=1 #if(:t.man!=''){ AND man LIKE '%##(:t.man)%' } #if(:t.manCard!=''){ AND manCard LIKE '%##(:t.manCard)%' } #if(:t.woman!=''){ AND woman LIKE '%##(:t.woman)%' } #if(:t.womanCard!=''){ AND womanCard LIKE '%##(:t.womanCard)%' } ORDER BY orderAt DESC,createAt desc LIMIT :t.start ,:t.length")
    List<MarriageInfor> queryList(@SQLParam("t") MarriageInfor marriageInfor);
    
    @SQL("SELECT count(1) FROM	MarriageInfor WHERE 1=1 #if(:t.man!=''){ AND man LIKE '%##(:t.man)%' } #if(:t.manCard!=''){ AND manCard LIKE '%##(:t.manCard)%' } #if(:t.woman!=''){ AND woman LIKE '%##(:t.woman)%' } #if(:t.womanCard!=''){ AND womanCard LIKE '%##(:t.womanCard)%' }")
    int querysize(@SQLParam("t") MarriageInfor marriageInfor);

    @SQL("UPDATE MarriageInfor SET orderAt=now() WHERE id=:1")
    void updateByStickTime(String id);
	
	@SQL("UPDATE MarriageInfor SET orderAt=null WHERE id=:1")
    void updateByStickTimeIsNull(String id);
	
	@SQL("SELECT id,code,man,manCard,woman,womanCard,type,regTime,addressId,link,status,createAt FROM MarriageReg where createAt > :1 and createAt < :2 and addressId in (:li)")
	List<Map> marriageInforExcel(String createAt,String endAt,@SQLParam("li") List<Integer> addressIds);
	
	@SQL("SELECT id,code,man,manPhone,woman,womanPhone,createAt,addressId FROM MarriageTJ where createAt > :1 and createAt < :2 ")
	List<Map> marriageTJExcel(String createAt,String endAt);
}